package org.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
import org.example.pojo.ItripComment;
import org.example.vo.recommend.hotelrecommend.Recommend_Comment;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ItripCommentMapper extends BaseMapper<ItripComment> {
    @Select({"select ih.id,count(ic.hotelId) countComment,avg(ic.score) score from itrip_comment ic\n" +
            "left join itrip_hotel ih on ih.id = ic.hotelId\n" +
            "where ic.productType = 1 and ic.hotelId = #{hotelid}"})
    @Results({
            @Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true),
            @Result(column="countComment", property="countComment", jdbcType= JdbcType.BIGINT),
            @Result(column="score", property="score", jdbcType= JdbcType.DOUBLE),
    })
    Recommend_Comment queryByHotelComment(Long hotelid);
}
